<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第一个案例</title>
    <style>
        .top {
            width: 300px;
            height: 50px;
            margin: 0 auto;
        }
        .box {
            width: 100px;
            height: 100px;
            background-color: slateblue;
            margin: 20px auto;
        }
    </style>
</head>
<body>
    <div class="top">
        <button class="widths">变宽</button>
        <button class="heights">变高</button>
        <button class="colors">变色</button>
        <button class="shows">隐藏</button>
        <button class="chong">重置</button>
    </div>
    <div class="box"></div>
</body>
<script>
    var box = document.querySelector('.box')
    // 变宽
    var widths = document.querySelector('.widths')
    widths.onclick = function () {
        box.style.width = '200px'
    } 
    // 变高
    var heights = document.querySelector('.heights')
    heights.onclick = function() {
        box.style.height = '200px'
    }
    // 变色
    var colors = document.querySelector('.colors')
    colors.onclick = function() {
        box.style.backgroundColor = 'red'
    }
    // 隐藏
    var shows = document.querySelector('.shows')
    shows.onclick = function() {
        box.style.display = "none"
    }
    // 重置
    var chong = document.querySelector('.chong')
    chong.onclick = function() {
        box.style = {
            width:'100px',
            height:'100px'
        }
    }
    
</script>
</html>